<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>添加操作人员</title>
    <%@include file="../../include/treeview.jsp" %>
    <%@include file="../../include/validate.jsp" %>
   	<style>
		.user_role>span{ display:block; margin-top:5px;}
		.user_role>span .checker{display:inline-block}
		.user_role>span>label{display:inline-block;vertical-align:middle;}
	</style>
</head>
<body>
<div class="row-fluid profile">
    <div class="span12">
        <!--BEGIN TABS-->
        <div class="tabbable tabbable-custom tabbable-full-width">
            <ul class="nav nav-tabs">
                <li><a href="${ctx}/operator/list">操作人员列表</a></li>
                <li class="active"><a href="${ctx}/operator/form">添加操作人员</a></li>
            </ul>
            <div class="tab-content">
                <!--end tab-pane-->
                <div class="tab-pane profile-classic row-fluid active" id="tab_1_2">
                    <div class="span12">
                        <!-- BEGIN SAMPLE FORM PORTLET-->
                        <div class="portlet box blue">
                            <div class="portlet-title">
                                <div class="caption">
                                    <i class="icon-reorder"></i> <span class="hidden-480">添加操作人员</span>
                                </div>
                            </div>
                            <!-- END SAMPLE FORM PORTLET-->
                            <div class="portlet-body form">
                                <%--<form class="form-horizontal" action="${ctx}/operator/save" id="form" method="post">--%>
                                <form:form id="inputForm" modelAttribute="operator" action="${ctx}/operator/save" method="post" class="form-horizontal">
                                    <fieldset>
                                        <form:hidden path="id"/>
                                        <form:hidden path="version"/>
                                       	<%-- <form:hidden path="password"/> --%>
                                        <form:hidden path="lastLoginTime"/>
                                        <form:hidden path="lastLoginIp"/>
                                        <form:hidden path="loginCount"/>
                                        <form:hidden path="createTime"/>
                                        <form:hidden path="modifyTime"/>
										<form:hidden path="merchantId"/>
                                        <div class="control-group">

                                            <!-- Text input-->
                                            <label class="control-label" for="input01">真实姓名</label>

                                            <div class="controls">
                                                <input type="text" placeholder="真实姓名" value="${operator.realName}" name="realName" class="m-wrap input-xlarge">

                                                <p class="help-block"></p>
                                            </div>
                                        </div>

                                        <div class="control-group">

                                            <!-- Text input-->
                                            <label class="control-label" for="input01">登录名</label>

                                            <div class="controls">
                                                <input type="text" placeholder="登录名" name="loginName" value="${operator.loginName}" class="m-wrap input-xlarge">

                                                <p class="help-block"></p>
                                            </div>
                                        </div>
                                          <div class="control-group">

                                            <!-- Text input-->
                                            <label class="control-label" for="input01">密码</label>

                                            <div class="controls">
                                                <input type="password" placeholder="请输入密码" name="password" id="password" value="" class="m-wrap input-xlarge">

                                                <p class="help-block"></p>
                                            </div>
                                        </div>
                                        <div class="control-group">
                                            <label class="control-label">状态</label>

                                            <div class="controls">
                                                <!-- Inline Radios -->
                                                <label class="radio inline"> <input type="radio" value="0" name="status" checked="checked"> 正常 </label>
                                                <label class="radio inline"> <input type="radio" value="1" name="status"> 禁用 </label>
                                            </div>
                                        </div>

                                        <div class="control-group">
                                            <label class="control-label">用户角色</label>
										
                                            <div class="controls user_role">
                                            <c:forEach items="${allRoles}" var="list" varStatus="status">
                                            	<c:choose>
                                            		<c:when test="${list.id== operator.roles[0].id}">
                                            			<div><label class="radio inline"> <input type="radio" value="${list.id }" name="roleIdList" checked> ${list.name } </label></div>
                                            		</c:when>
                                            		<c:when test="${list.id!= operator.roles[0].id && status.index==0}">
                                            			<div><label class="radio inline"> <input type="radio" value="${list.id }" name="roleIdList" checked> ${list.name } </label></div>
                                            		</c:when>
                                            		<c:otherwise>
                                            			<div><label class="radio inline"> <input type="radio" value="${list.id }" name="roleIdList"> ${list.name } </label></div>
                                            		</c:otherwise>
                                            	</c:choose>
                                            </c:forEach>
                                                <span class="help-inline"><font color="red"></font> </span>
                                            </div>
                                        </div>

                                    </fieldset>
                                    <div class="form-actions">
                                        <button type="submit" class="btn blue" >
                                            <i class="icon-ok"></i> 保存
                                        </button>
                                        <button type="button" class="btn" onclick="history.go(-1)">取消</button>
                                    </div>
                                </form:form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--END TABS-->
        </div>
    </div>
</div>


<script type="text/javascript">

    $(function () {

        $("#inputForm").validate({
            rules: {
                //name: {remote: "${ctx}/sys/operator/checkName?oldName=" + encodeURIComponent("${operator.realName}")}
            },
            messages: {
                //name: {remote: "角色名已存在"}
            },
            submitHandler: function (form) {
         /*        var ids = [], nodes = tree.getCheckedNodes(true);
                for (var i = 0; i < nodes.length; i++) {
                    ids.push(nodes[i].id);
                }
                $("#roleIds").val(ids);
             */
                //loading('正在提交，请稍等...');
             
             var password =$("#password").val();
             if(password == null || password == ""){
            	 alertBasic("提示信息","密码不能为空",null,1);
            	 return ;
             }
             if(password.length < 6){
            	 alertBasic("提示信息","密码不能少于6位",null,1);
            	 return ;
             }             
                form.submit();
            }
        });
        
       
        
    });

    
    
</script>
</body>
</html>